package routers

import (
	"dc-news-admin-api/common/middleware/jwt"
	"dc-news-admin-api/controller"
	"github.com/gin-gonic/gin"
)

func SetupAdminRouter(r *gin.Engine) {
	v1Group := r.Group("api/v1")
	noAuthGroup := v1Group.Group("")
	{
		noAuthGroup.POST("login", controller.LoginHandler)
	}
	authGroup := v1Group.Group("admin")
	authGroup.Use(jwt.Auth("su"))
	{
		authGroup.POST("", controller.CreateAdminHandler)
		authGroup.PUT("/:id/role", controller.ModifyAdminAuthHandler)
		authGroup.PUT("/:id/password", controller.ResetPasswordHandler)
		authGroup.DELETE("/:id", controller.DeleteAdminHandler)
		authGroup.GET("list", controller.GetAdminListHandler)
	}
}
